package com.cloud.business.enums;

import com.cloud.business.constant.Constants;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ResultEnum implements ErrorType {

    ERROR("操作失败", Constants.FAIL),
    SUCCESS("操作成功", Constants.SUCCESS),
    UNSUPPORTED_REQUEST_METHOD("不支持的请求方式",Constants.FAIL),
    ;

    private String msg;

    private Integer code;

    //根据值获取key
    public static ResultEnum getEnumByCode(Integer code){
        for(ResultEnum resultEnum : ResultEnum.values()){
            if(code.equals(resultEnum.getCode())){
                return resultEnum;
            }
        }
        return null;
    }
}
